<template>
  <div style="height: 100%;overflow:hidden"
       class="main">
    <x-header :left-options="{preventGoBack:true,backText: ''}"
              @on-click-back="backhome">安全整改单</x-header>
    <div class="main-container"
         style="overflow:auto;height:93%">
      <v-touch v-on:swiperight="onSwipeRight"
               :swipe-options="{direction: 'horizontal'}">
        <!-- <div id="map"></div> -->
        <div>
          <group>
            <!-- <cell title='项目（部）'
                  v-model="pro"
                  is-link
                  link='proListR1'></cell> -->
            <select-project
                title="项目（部）"
                formType="rectify"
                module="danger"
                status="add"
                :showValue="true"
                v-model="pro"
                @selectPro="selectPro"
              ></select-project>
            <!-- <span>{{pro}}</span>  -->
            <calendar v-model="checkDateS"
                      title="检查日期开始"
                      @on-change="fillDetail"> </calendar>
            <calendar v-model="checkDateE"
                      title="检查日期截至"
                      @on-change="fillDetail"> </calendar>
            <x-input title="监理单位"
                     v-model="supervision"
                     text-align=right></x-input>
            <x-input title="施工单位"
                     v-model="construct"
                     text-align=right></x-input>
            <!-- <popup-radio title="总监理工程师"
                         :options="options1"
                         v-model="option"></popup-radio>
            <popup-radio title="项目经理"
                         :options="options1"
                         v-model="option2"></popup-radio>
            <popup-radio title="项目安全主任"
                         :options="options1"
                         v-model="option3"></popup-radio> -->
            <group title="检查类型">
              <x-textarea placeholder="请输入检查类型概况"
                          v-model="DESCRIPTION"></x-textarea>
            </group>
            <group>
              <cell title="整改内容明细">
                <x-icon id="headeright"
                        type="ios-arrow-up"
                        size="30"
                        @click="showDetail"
                        v-if="isActive"></x-icon>
                <x-icon id="headeright"
                        type="ios-arrow-down"
                        size="30"
                        @click="showDetail"
                        v-if="!isActive"></x-icon>
              </cell>
              <pull>
                <div class="collapse-wrap"
                     v-show="isActive">
                  <slot>

                    <!-- 明细表内容 -->
                    <group v-for="(item, i) in listR"
                           :key="i">
                      <!-- <divider>——————————————————————————</divider> -->
                      <div class="sup"></div> 
                      <cell title="类别"
                            v-model="item.FATHERCLASS"></cell>
                      <cell title="检查项目"
                            v-model="item.CHECKPRO"></cell>
                      <cell title="检查项"
                            v-model="item.CHECKITEMS"></cell>
                      <cell title="描述"
                            v-model="item.DESCRIPTION"></cell>
                      <group title="检查图片">
                        <picture-upload :fieldToken='item.ATTACHMENTS'
                                        :pageToken='item.ATTACHMENTS'
                                        :value='item.ATTACHMENTS'
                                        :readonly='true'></picture-upload>
                      </group>
                      <cell title="上报人"
                            v-model="item.INPUTERFULLNAME"></cell>
                    </group>
                    <!-- <divider>——————————————————————————</divider> -->
                    <div class="sup"></div> 
                  </slot>
                </div>
              </pull>
            </group>
            <popup-radio title="是否停工"
                         :options="options2"
                         v-model="isStop"
                         @on-hide="toStop"></popup-radio>
            <group title="停工备注" v-show="stopContentFlag">
              <x-textarea v-model="STOPCONTENT"></x-textarea>
            </group>
            <calendar v-model="rectifyDate"
                      title="整改期限"> </calendar>
            <x-switch title="短信通知"
                      v-model="notifyMethod"
                      :value-map="['0,0,0','0,1,0']"
                      @on-change="loga"></x-switch>

            <group>
              <div class="cell_style">
                <person-tree title="检查组长"
                             v-model="person"
                             :personid="personId"
                             :defaultValue="personId"
                             @selectUser='selectPerson'></person-tree>
              </div>
            </group>

            <group>
              <div class="cell_style">
                <person-tree title="检查组员"
                             v-model="person5"
                             :personid="person5Id"
                             :defaultValue="person5Id"
                             @selectUser='selectPerson5'
                             :multiple=true></person-tree>
              </div>
            </group>

            <cell title="签发人"
                  v-model='name'></cell>
            <cell title="联系电话"
                  v-model='phone'></cell>
            <cell title="填写部门"
                  v-model='dept'></cell>
            <cell title="填写时间"
                  v-model='inputDate'></cell>
            <group>
              <div class="cell_style">
                <person-tree title="施工、监理确认"
                             v-model="person2"
                             :multiple=true
                             :personid="person2Id"
                             :defaultValue="person2Id"
                             @selectUser='selectPerson2'></person-tree>
              </div>
            </group>
            <group>
              <div class="cell_style">
                <person-tree title="施工单位整改"
                             v-model="person3"
                             :personid="person3Id"
                             :defaultValue="person3Id"
                             :multiple=true
                             @selectUser='selectPerson3'></person-tree>
              </div>
            </group>
            <group>
              <div class="cell_style">
                <person-tree title="监理单位审核"
                             v-model="person4"
                             :personid="person4Id"
                             :defaultValue="person4Id"
                             :multiple=true
                             @selectUser='selectPerson4'></person-tree>
              </div>
            </group>

            <cell title="复核人"
                  v-model="name"></cell>
            <group>
              <div class="cell_style">
                <person-tree title="项目负责人"
                             v-model="PRJMANAGERFULLNAME"
                            :personid="PRJMANAGERNAME"
                            :defaultValue="PRJMANAGERNAME"
                             @selectUser='selectPrjManagerFullName'></person-tree>
              </div>
            </group>
          </group>
          <div style="text-align:center;display:flex" class="top-border">
            <button :disabled="isDisabled" class="userBack-button_save" @click="saveRectifyDraft">暂存</button>
            <button :disabled="isDisabled" class="userBack-button_submit" @click="saveRectifyInfo">提交</button>
        </div>
            <Toast :value="toastValue"
                   :is-show-mask="true"
                   text="保存成功"
                   @on-hide="saveSuccess"></Toast>
            <Toast :value="toastValueErr"
                   :is-show-mask="true"
                   :text="err"
                   @on-hide="saveErr"
                   type="cancel"
                   width="200px"></Toast>
        </div>
      </v-touch>
    </div>
  </div>
</template>
 
<script>
import * as L from 'leaflet'
import pull from '@/views/hidangereport/pull-down.js'
import personTree from '@/components/tree/personTree'
//Vue.L = Vue.prototype.$L = L 
import { Group, Cell, XButton, Box, GroupTitle, Flexbox, FlexboxItem, Divider, Calendar, PopupPicker, Toast, XInput, InlineXSwitch, XSwitch, FormPreview, Loading, XTextarea } from 'vux'
var map = null;
var marker = null;
var flag = 0;
export default {
  components: {
    XButton,
    Box,
    GroupTitle,
    Group,
    Flexbox,
    FlexboxItem,
    Divider,
    Group,
    Cell,
    Calendar,
    PopupPicker,
    Toast,
    XInput,
    pull,
    personTree,
    InlineXSwitch,
    XSwitch,
    FormPreview,
    Loading,
    XTextarea
  },
  name: 'HelloWorld',
  data () {
    return {
      proId: this.$route.query.proId,
      pro: this.$route.query.pro,
      //prjId: this.$route.query.proId,
      name: this.$store.state.user.ADUSER_NAME,
      phone: this.$store.state.user.mobil,
      dept: this.$store.state.user.orgName,
      userId: this.$store.state.user.USER_NO,
      DESCRIPTION: "",
      pageToken: "",
      fieldToken: "",
      buttonid: "",
      inputDate: this.$store.state.user.loginTime,
      inputDateFix: "",
      // map:"",
      checkDateS: "",
      checkDateE: "",
      supervision: "",
      construct: "",
      rectifyDate: "",
      toastValue: false,
      toastValueErr: false,
      err: '',
      isActive: true,
      options1: ["在岗", "不在岗"],
      option: "在岗",
      option2: "在岗",
      option3: "在岗",
      options2: ["是", "否","部分停工"],
      isStop: "否",
      person: "",
      personId: "",
      person2: "",
      person2Id: "",
      person3: "",
      person3Id: "",
      person4: "",
      person4Id: "",
      person5: "",
      person5Id: "",
      fatherClass: [],
      checkPro: [],
      checkItems: [],
      descriptionDetail: [],
      image: [],
      listR: [],
      proNum: 0,
      fixStop: 0,
      notifyMethod: '0,0,0',
      notifyCheck:"",
      isDisabled:false,
      STOPCONTENT:"",
      stopContentFlag:false,
      RECTIFYNO:"",
      PRJMANAGERFULLNAME:this.$route.query.prjManagerFullName === undefined ? "" : this.$route.query.prjManagerFullName,
      PRJMANAGERNAME:this.$route.query.prjManagerName === undefined ? "" : this.$route.query.prjManagerName,
      isPm:"",
    }
  },
  methods: {
    selectPro(val){
      console.log(val);
      this.proId = val.id;
      this.pro = val.name;
      this.PRJMANAGERFULLNAME = val.prjManagerFullName;
      this.PRJMANAGERNAME = val.prjManagerName;
      this.isPm = val.isPm;
    },
    selectPrjManagerFullName(val){
      this.PRJMANAGERNAME = val;
    },
    //这五个函数真的是沙比写出来的cnmb
    selectPerson (val) {

      this.personId = val
    },
    selectPerson2 (val) {
      this.person2Id = val
      console.log(this.person2Id)
    },
    selectPerson3 (val) {

      this.person3Id = val
    },
    selectPerson4 (val) {

      this.person4Id = val
    },
    selectPerson5 (val) {

      this.person5Id = val
    },
    toStop () {
      if (this.isStop == '是'){
        this.fixStop = 1
        this.stopContentFlag = false
      }else if(this.isStop == '否'){
        this.fixStop = 0
        this.stopContentFlag = false
      }else{
        this.fixStop = 3
        this.stopContentFlag = true
      }
    },
    loga (value) {
      console.log("value" + value)
      console.log("notifyMethod" + this.notifyMethod)
      console.log(this.person)
    },
    showDetail () {
      this.isActive = !this.isActive;
    },
    onSwipeRight () {
      this.$router.push({ path: '/hidangereport', query: { flag: 1 } })
    },
    fillDetail () {
      console.log(this.checkDateS, this.checkDateE, this.proId)
      // var params = '{"_method":"component.getListData","_param":{"bizObj":"PMHSE_RECTIFY","service":"selectMore","fields":"*","filter":' + '"' + filter + '"' + ',"currentPageIndex":1,"pageSize":50,"orderList":[{"field":"NUMZZ","order":"DESC"}],"QueryFormData":""}}';
      var params = '{"_method":"PMHSE_RECTIFY.FillDetail","CHECKDATES":"' + this.checkDateS + '","CHECKDATEE":"' + this.checkDateE + '","CONSTRUCTPRO":"' + this.proId + '"}';
      this.$ajax({
        method: 'post',
        url: this.COMMON_URL + '?_objName=PMHSE_RECTIFY&_viewId=PMHSE_RECTIFY',
        data: {
          FixJSON: params
        }
      }).then((res) => {
        this.listR = res.data.list;
        console.log(this.listR)
        this.proNum = this.listR.length;
        console.log(this.listR.length)
      })
    },
    //     openSumlist(item) {
    //     //this.$store.commit('SET_CURRENT_ROW', item);
    //     this.$router.push({path:'/hidangereport',query:{pro:""}})
    // },
    backhome () {
      // this.$router.push('/hidangereport');
      this.$router.push({ path: '/hidangereport_new', query: { flag: 1 } })
      this.$vux.loading.hide();
    },
    setRowData (DataTarget, Value, OriginalValue, PK, DataType) {
      var map = {};
      map["DataTarget"] = DataTarget;
      map["Value"] = Value;
      map["OriginalValue"] = OriginalValue;
      map["PK"] = PK;
      map["DataType"] = DataType;
      return map;
    },
    setChildData (rowData) {
      var map = {};
      map["rowData"] = rowData;
      map["children"] = [];
      return map;
    },
    saveRectifyInfo () {
        var guid = this.guid();
        var title = "安全整改通知单提醒";
        var content = "你管理的" + this.pro + "项目有一个新的安全整改通知单。请进入【安全整改通知单】查看详细信息。";
        var messageto = this.PRJMANAGERNAME;
        var url = process.env.BASE_URL + "qhszpm/forms/PMHSE/PMHSE_RECTIFY/PMHSE_RECTIFY_ADD.html?isBreak=false&objName=PMHSE_RECTIFY&_useType=view&_pk=GUID&_t=295548&_winid=w274&_pkValue=" + guid;

        var sendParams = {
          "_method":"SYS_NOTICE.sendNotice",
          "_param":{
            "messageto":messageto,
            "messagetilte":title,
            "messagecontent":content,
            "url":url,
            "messagesenttime":new Date(),
            "messageattachment":""
            } 
        }

        let sendJson = {
          FixJSON: JSON.stringify(sendParams),
        }
        this.$ajax({
          url : this.COMMON_URL,
          method : "post",
          // data: this.signMD5(sendJson)
          data: sendJson
        }).then(res => {
         }).catch((err) => {
           console.log(err);
        });

      console.log(this.person2Id)
      this.isDisabled = true;
      if(this.notifyMethod == "0,1,0"){
        this.notifyCheck = "SMS"
      }
      this.err = '';
      if (!this.pro) {
        this.err += "【项目（部）】不能为空<br/>";
      }
      if (this.checkDateS == '') {
        this.err += "【检查日期开始】不能为空<br/>";
        //console.log(this.FATHERCLASS.length)
      }
      if (this.checkDateE == '') {
        this.err += "【检查日期截至】不能为空<br/>";
        //console.log(this.FATHERCLASS.length)
      }
      if (this.supervision == '') {
        this.err += "【监理单位】不能为空<br/>";
      }
      if (this.construct == '') {
        this.err += "【施工单位】不能为空<br/>";
      }
      if (this.DESCRIPTION == '') {
        this.err += "【整改内容】不能为空<br/>";
      }
      if (this.rectifyDate == '') {
        this.err += "【整改期限】不能为空<br/>";
      }
      if (this.person == '') {
        this.err += "【检查组长】不能为空<br/>"
      }
      if (this.person5 == '') {
        this.err += "【检查组员】不能为空<br/>"
      }
      if (this.person2 == '') {
        this.err += "【施工、监理确认】不能为空<br/>"
      }
      if (this.person3 == '') {
        this.err += "【施工单位整改】不能为空<br/>"
      }
      if (this.person4 == '') {
        this.err += "【监理单位审核】不能为空<br/>"
      }
      // if (this.PRJMANAGERFULLNAME == '') {
      //   this.err += "【项目负责人】不能为空<br/>"
      // }
      if (this.err != "") {
        this.toastValueErr = true;
        this.isDisabled = false;
        return false;
      }
      var rowData = [this.proNum];
      var childData = [];
      var i = 0;
      for (i = 0; i < this.proNum; i++) {
        rowData[i] = new Array();
        rowData[i][0] = this.setRowData("GUID", "", null, true, "String");
        rowData[i][1] = this.setRowData("PRJNO", this.listR[i].SYSPRJID, null, false, "String");
        rowData[i][2] = this.setRowData("FATHERCLASS", this.listR[i].FATHERCLASS, null, false, "String");
        rowData[i][3] = this.setRowData("PROJECTNO", this.listR[i].PROJECTID, null, false, "String");
        rowData[i][4] = this.setRowData("CHECKPRO", this.listR[i].CHECKPRO, null, false, "String");
        rowData[i][5] = this.setRowData("CHECKITEMS", this.listR[i].CHECKITEMS, null, false, "String");
        rowData[i][6] = this.setRowData("DESCRIPTION", this.listR[i].DESCRIPTION, null, false, "String");
        rowData[i][7] = this.setRowData("RECTIFYSTATE", "未整改", null, false, "String");
        rowData[i][8] = this.setRowData("IMAGE", this.listR[i].ATTACHMENTS, null, false, "Store.ecidiDoc");
        rowData[i][9] = this.setRowData("REMARK", this.listR[i].GUID, null, false, "String");
        rowData[i][10] = this.setRowData("EXPLANATION", "", null, false, "String");
        rowData[i][11] = this.setRowData("RECTIFYIMAGE", "", null, false, "Store.ecidiDoc");
        rowData[i][12] = this.setRowData("REPROTPEOPLE", this.listR[i].INPUTERFULLNAME, null, false, "String");
        rowData[i][13] = this.setRowData("RECTIFYSTATE_TEXT", "", null, false, "String");
        rowData[i][14] = this.setRowData("CONSTRUCTPRO", this.proNum, null, false, "String");
        rowData[i][15] = this.setRowData("IMPORTANCE", this.listR[i].IMPORTANCE, null, false, "String");
        rowData[i][16] = this.setRowData("WEIGHT", this.listR[i].WEIGHT, null, false, "String");
        rowData[i][17] = this.setRowData("CHILDCLASS", this.listR[i].CHILDCLASS, null, false, "String");
        rowData[i][18] = this.setRowData("INPUTMONTH", this.listR[i].CHECKDATE, null, false, "TimeStamp");
        //rowData[i] = JSON.stringify(rowData[i]);
        //console.log(rowData[i])
        childData[i] = this.setChildData(rowData[i]);
        //console.log(childData[i]);
      }
      //childData = JSON.stringify(childData)
      //childData = JSON.stringify(childData).replace('"', '').replace(/[\\]/g, '')
      //childData = JSON.stringify(childData).replace('\\', '')
      //console.log(childData);
      //console.log(rowData)
      var params = {
        "_method": "formService.saveFormData",
        "requestEventData": {
          "eventType": "formSubmitEvent",
          "formType": 1,
          "bizObjId": "PMHSE_RECTIFY",
          "formId": "PMHSE_RECTIFY_ADD",
          "buttonId": "HandleCommand_1"        },
        "flowParam": {
          "defKey": "PMHSE_RECTIFY_ADD",
          "nodeId": "UserTask_1",
          "userCommandType": "startandsubmit",
          "userCommandId": "HandleCommand_1",
          "isAdmin": "false",
          "taskComment": "", "extParam": {}        },
        "_OBJ_NAME_": "PMHSE_RECTIFY",
        "_FORM_ID_": "PMHSE_RECTIFY_ADD",
        "useType": "add",
        "pageToken": this.guid(),
        "formData": {
          "objName": "PMHSE_RECTIFY",
          "pks": ["GUID"],
          "data": [{            "rowData": [
              { "DataTarget": "GUID", "Value": guid, "OriginalValue": null, "PK": true, "DataType": "String" },
              { "DataTarget": "RECTIFYNO", "Value": this.RECTIFYNO, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "STATE", "Value": "", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PRJNAME", "Value": this.pro, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "SYSPRJID", "Value": this.proId, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "CHECKDATES", "Value": this.checkDateS, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "CHECKDATEE", "Value": this.checkDateE, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "SUPERVISIONUNIT", "Value": this.supervision, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "CONSTRUCTIONUNIT", "Value": this.construct, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PROCHIEF", "Value": this.option, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PROMANAGE", "Value": this.option2, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PROLEADER", "Value": this.option3, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYCONTENT", "Value": this.DESCRIPTION, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYCOMNUM", "Value": 0, "OriginalValue": null, "PK": false, "DataType": "int" },
              { "DataTarget": "RECTIFYNUM", "Value": this.proNum, "OriginalValue": null, "PK": false, "DataType": "int" },
              { "DataTarget": "CLOSERATE", "Value": "0%", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "FLAG", "Value": "", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "STTEMP", "Value": "", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "ISSTOP", "Value": this.fixStop, "OriginalValue": null, "PK": false, "DataType": "int" },
              { "DataTarget": "STOPCONTENT", "Value": this.STOPCONTENT, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYDATE", "Value": this.rectifyDate, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "NOTIFYCHECK", "Value": this.notifyCheck, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "NOTIFYMETHOD", "Value": this.notifyMethod, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INSPECTIONCHIEF", "Value": this.person, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INSPECTIONMEMBER", "Value": this.person5, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTERFULLNAME", "Value": this.name, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTERNAME", "Value": this.userId, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PHONENUM", "Value": this.phone, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTERDEPTNAME", "Value": this.dept, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTDATE", "Value": this.inputDate, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "AUDITUSERFULLNAME", "Value": this.person2, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME", "Value": this.person2Id, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERFULLNAME2", "Value": this.person3, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME2", "Value": this.person3Id, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERFULLNAME3", "Value": this.person4, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME3", "Value": this.person4Id, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERFULLNAME4", "Value": this.name, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME4", "Value": this.userId, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PRJMANAGERFULLNAME", "Value": this.PRJMANAGERFULLNAME, "OriginalValue": null, "PK": false, "DataType": "String" },
               { "DataTarget": "PRJMANAGERNAME", "Value": this.PRJMANAGERNAME, "OriginalValue": null, "PK": false, "DataType": "String" },
               { "DataTarget": "ISPM", "Value": this.isPm, "OriginalValue": null, "PK": false, "DataType": "String" }
              ],
            "children": [{ "objName": "PMHSE_RECTIFY_DETAILES", "pks": ["GUID"], "data": childData }]          }]        },
        "_ATTACHMENT_DELETE_IDS_": "",
        "formInfo": {}
      }
      let json = {
        FixJSON: JSON.stringify(params),
      }
      this.$ajax({
        url: this.COMMON_URL, //+ '?_objName=PMHSE_RECTIFY&_useType=add&_defKey=PMHSE_RECTIFY_ADD&_pk=GUID&_pkValue=undefined',
        method: 'post',
        // data: this.signMD5(json)
        data:json
      }).then(res => {
        console.log("错误response",res);
        this.$vux.loading.show({
          text: "Loading"
        })
        for (i = 0; i < this.proNum; i++) {
          this.changState(this.listR[i].GUID)
        }
        this.toastValue = true;
      }).catch((err) => {
        this.isDisabled = false;
        alert(err);
      });
    },
    changState (guid) {
      let params = {
        FixJSON: { "_method": "PMHSE_RECTIFY.changeState", "GUID": guid }
      }
      this.$ajax({
        url: this.COMMON_URL + "?_objName=PMHSE_RECTIFY&_useType=add&_defKey=PMHSE_RECTIFY_ADD&_pk=GUID&_pkValue=undefined",
        method: 'post',
        params: params
      }).then(res => {
        console.log("success")
      })
    },
    saveRectifyDraft () {
      this.isDisabled = true
      if(this.notifyMethod == '0.1.0'){
        this.notifyCheck = "SMS"
      }
      var rowData = [this.proNum];
      var childData = [];
      var i = 0;
      for (i = 0; i < this.proNum; i++) {
        rowData[i] = new Array();
        rowData[i][0] = this.setRowData("GUID", "", null, true, "String");
        rowData[i][1] = this.setRowData("PRJNO", this.listR[i].SYSPRJID, null, false, "String");
        rowData[i][2] = this.setRowData("FATHERCLASS", this.listR[i].FATHERCLASS, null, false, "String");
        rowData[i][3] = this.setRowData("PROJECTNO", this.listR[i].PROJECTID, null, false, "String");
        rowData[i][4] = this.setRowData("CHECKPRO", this.listR[i].CHECKPRO, null, false, "String");
        rowData[i][5] = this.setRowData("CHECKITEMS", this.listR[i].CHECKITEMS, null, false, "String");
        rowData[i][6] = this.setRowData("DESCRIPTION", this.listR[i].DESCRIPTION, null, false, "String");
        rowData[i][7] = this.setRowData("RECTIFYSTATE", "未整改", null, false, "String");
        rowData[i][8] = this.setRowData("IMAGE", this.listR[i].ATTACHMENTS, null, false, "Store.ecidiDoc");
        rowData[i][9] = this.setRowData("REMARK", this.listR[i].GUID, null, false, "String");
        rowData[i][10] = this.setRowData("EXPLANATION", "", null, false, "String");
        rowData[i][11] = this.setRowData("RECTIFYIMAGE", "", null, false, "Store.ecidiDoc");
        rowData[i][12] = this.setRowData("REPROTPEOPLE", this.listR[i].INPUTERFULLNAME, null, false, "String");
        rowData[i][13] = this.setRowData("RECTIFYSTATE_TEXT", "", null, false, "String");
        rowData[i][14] = this.setRowData("CONSTRUCTPRO", this.proNum, null, false, "String");
        rowData[i][15] = this.setRowData("IMPORTANCE", this.listR[i].IMPORTANCE, null, false, "String");
        rowData[i][16] = this.setRowData("WEIGHT", this.listR[i].WEIGHT, null, false, "String");
        rowData[i][17] = this.setRowData("CHILDCLASS", this.listR[i].CHILDCLASS, null, false, "String");
        rowData[i][18] = this.setRowData("INPUTMONTH", this.listR[i].CHECKDATE, null, false, "TimeStamp");
        //rowData[i] = JSON.stringify(rowData[i]);
        //console.log(rowData[i])
        childData[i] = this.setChildData(rowData[i]);
        //console.log(childData[i]);
      }
      //childData = JSON.stringify(childData)
      //childData = JSON.stringify(childData).replace('"', '').replace(/[\\]/g, '')
      //childData = JSON.stringify(childData).replace('\\', '')
      //console.log(childData);
      //console.log(rowData)
      var params = {
        "_method": "formService.saveFormData",
        "requestEventData": {
          "eventType": "formSubmitEvent",
          "formType": 1,
          "bizObjId": "PMHSE_RECTIFY",
          "formId": "PMHSE_RECTIFY_ADD",
          "buttonId": "HandleCommand_3"        },
        "flowParam": {
          "defKey": "PMHSE_RECTIFY_ADD",
          "nodeId": "UserTask_1",
          "userCommandType": "saveTaskDraft",
          "userCommandId": "HandleCommand_3",
          "isAdmin": "false",
          "taskComment": "", "extParam": {}        },
        "_OBJ_NAME_": "PMHSE_RECTIFY",
        "_FORM_ID_": "PMHSE_RECTIFY_ADD",
        "useType": "add",
        "pageToken": this.guid(),
        "formData": {
          "objName": "PMHSE_RECTIFY",
          "pks": ["GUID"],
          "data": [{            "rowData": [
              { "DataTarget": "GUID", "Value": "", "OriginalValue": null, "PK": true, "DataType": "String" },
               { "DataTarget": "RECTIFYNO", "Value": this.RECTIFYNO, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "STATE", "Value": "", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PRJNAME", "Value": this.pro, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "SYSPRJID", "Value": this.proId, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "CHECKDATES", "Value": this.checkDateS, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "CHECKDATEE", "Value": this.checkDateE, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "SUPERVISIONUNIT", "Value": this.supervision, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "CONSTRUCTIONUNIT", "Value": this.construct, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PROCHIEF", "Value": this.option, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PROMANAGE", "Value": this.option2, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PROLEADER", "Value": this.option3, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYCONTENT", "Value": this.DESCRIPTION, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYCOMNUM", "Value": 0, "OriginalValue": null, "PK": false, "DataType": "int" },
              { "DataTarget": "RECTIFYNUM", "Value": this.proNum, "OriginalValue": null, "PK": false, "DataType": "int" },
              { "DataTarget": "CLOSERATE", "Value": "0%", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "FLAG", "Value": "", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "STTEMP", "Value": "", "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "ISSTOP", "Value": this.fixStop, "OriginalValue": null, "PK": false, "DataType": "int" },
              { "DataTarget": "STOPCONTENT", "Value": this.STOPCONTENT, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "RECTIFYDATE", "Value": this.rectifyDate, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "NOTIFYCHECK", "Value": this.notifyCheck, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "NOTIFYMETHOD", "Value": this.notifyMethod, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INSPECTIONCHIEF", "Value": this.person, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INSPECTIONMEMBER", "Value": this.person5, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTERFULLNAME", "Value": this.name, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTERNAME", "Value": this.userId, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PHONENUM", "Value": this.phone, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTERDEPTNAME", "Value": this.dept, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "INPUTDATE", "Value": this.inputDate, "OriginalValue": null, "PK": false, "DataType": "TimeStamp" },
              { "DataTarget": "AUDITUSERFULLNAME", "Value": this.person2, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME", "Value": this.person2Id, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERFULLNAME2", "Value": this.person3, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME2", "Value": this.person3Id, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERFULLNAME3", "Value": this.person4, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME3", "Value": this.person4Id, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERFULLNAME4", "Value": this.name, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "AUDITUSERNAME4", "Value": this.userId, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PRJMANAGERFULLNAME", "Value": this.PRJMANAGERFULLNAME, "OriginalValue": null, "PK": false, "DataType": "String" },
              { "DataTarget": "PRJMANAGERNAME", "Value": this.PRJMANAGERNAME, "OriginalValue": null, "PK": false, "DataType": "String" }
              ],
            "children": [{ "objName": "PMHSE_RECTIFY_DETAILES", "pks": ["GUID"], "data": childData }]          }]        },
        "_ATTACHMENT_DELETE_IDS_": "",
        "formInfo": {}
      }
      let json = {
        FixJSON: JSON.stringify(params),
      }
      this.err = '';
      if (!this.pro) {
        this.err += "【项目（部）】不能为空<br/>";
      }
      if (this.err != "") {
        this.toastValueErr = true;
        this.isDisabled = false;
        return false;
      }

      this.$ajax({
        url: this.COMMON_URL, //+ '?_objName=PMHSE_RECTIFY&_useType=add&_defKey=PMHSE_RECTIFY_ADD&_pk=GUID&_pkValue=undefined',
        method: 'post',
        // data: this.signMD5(json)
        data:json
      }).then(res => {
        // for (i = 0; i < this.proNum; i++) {
        //   this.changState(this.listR[i].GUID)
        // }
        this.$vux.loading.show({
          text:"Loading"
        })
        this.toastValue = true;
      }).catch((err) => {
        this.isDisabled = false;
        alert(err);
      });
    },
    saveSuccess () {
      this.backhome();
    },
    saveErr () {
      this.toastValueErr = false;
    },
    /**
     * 设置默认的检查日期，格式为xxxx-xx-xx
     */
    setDefautlDate () {
      let now = new Date();
      let month = now.getMonth() + 1;
      let day = now.getDate();
      if (month < 10) {
        month = '0' + month
      }
      if (day < 10) {
        day = "0" + day
      }
      //this.checkDate = now.getFullYear() + "-" + month + "-" + day;
      this.inputDate = now.getFullYear() + "-" + month + "-" + day;
      //this.dateChange()
    }
  },
  mounted () {
    this.setDefautlDate();
    this.$ajax({
                url : this.COMMON_URL,
                method : 'post',
                // data : this.signMD5({
                //     _method : "PMHSE_RECTIFY.setRectifyno",
                //     filter : ""
                // }),
                data : {
                    _method : "PMHSE_RECTIFY.setRectifyno",
                    filter : ""
                },
                async : false
            }).then(res =>{
                this.RECTIFYNO=res.data.RECTIFYNO;
            })
    if (this.proId) {
      var parameter = {
        _method: "component.getListData",
        _param: {
          bizObj: "PMBASE_PRJMANAG",
          service: "selectPMStaffMore",
          fields: "*",
          filter: "1=1 AND PROJECTID='" + this.proId + "'",
          currentPageIndex: 1,
          pageSize: 50,
          orderList: [
            {
              field: "ISPRJMANAG",
              order: "desc"
            }, {
              field: "INPUTDATE", "order": "desc"
            }], QueryFormData: ""        }
      }
      this.$ajax({
        method: 'post',
        url: this.COMMON_URL,
        data: { FixJSON: JSON.stringify(parameter) }
      }).then(res => {
        var data = res.data.datas
        this.supervision = data[0].SECURITYDEPTNAME2
        this.construct = data[0].SECURITYDEPTNAME
        if (data[0].SECURITYUSERFULLNAME && data[0].SECURITYUSERFULLNAME2) {
          this.person2 = data[0].SECURITYUSERFULLNAME + "," + data[0].SECURITYUSERFULLNAME2
          this.person2Id = data[0].SECURITYUSERNAME + "," + data[0].SECURITYUSERNAME2
        }
        if (data[0].SECURITYUSERFULLNAME && data[0].SECURITYUSERNAME) {
          this.person3 = data[0].SECURITYUSERFULLNAME
          this.person3Id = data[0].SECURITYUSERNAME
        }
        if (data[0].SECURITYUSERFULLNAME2 && data[0].SECURITYUSERNAME2) {
          this.person4 = data[0].SECURITYUSERFULLNAME2
          this.person4Id = data[0].SECURITYUSERNAME2
        }
      })
    }
  },
  watch: {
    // person: {
    //   handler (newval) {
    //     this.personId = localStorage.handleName;
    //   }
    // },
    // person2: {
    //   handler (newval) {
    //     this.person2Id = localStorage.handleName;
    //   }
    // },
    // person3: {
    //   handler (newval) {
    //     this.person3Id = localStorage.handleName;
    //   }
    // },
    // person4: {
    //   handler (newval) {
    //     this.person4Id = localStorage.handleName;
    //   }
    // },
    // person5: {
    //   handler (newval) {
    //     this.person5Id = localStorage.handleName;
    //   }
    // },
    isStop: {
      handler (newval, oldval) {
        if (newval == '是')
          this.fixStop = 1
        else
          this.fixStop = 0
        console.log(this.fixStop)
      }
    },
    proId: {
      handler () {
        var parameter = {
          _method: "component.getListData",
          _param: {
            bizObj: "PMBASE_PRJMANAG",
            service: "selectPMStaffMore",
            fields: "*",
            filter: "1=1 AND PROJECTID='" + this.proId + "'",
            currentPageIndex: 1,
            pageSize: 50,
            orderList: [
              {
                field: "ISPRJMANAG",
                order: "desc"
              }, {
                field: "INPUTDATE", "order": "desc"
              }], QueryFormData: ""          }
        }
        this.$ajax({
          method: 'post',
          url: this.COMMON_URL,
          data: { FixJSON: JSON.stringify(parameter) }
        }).then(res => {
          var data = res.data.datas
          this.supervision = data[0].SECURITYDEPTNAME2
          this.construct = data[0].SECURITYDEPTNAME

          if(data[0].SECURITYUSERFULLNAME != "" && data[0].SECURITYUSERFULLNAME2 !=""){
            this.person2 = data[0].SECURITYUSERFULLNAME + "," + data[0].SECURITYUSERFULLNAME2
            this.person2Id = data[0].SECURITYUSERNAME + "," + data[0].SECURITYUSERNAME2
			}else if(data[0].SECURITYUSERFULLNAME != "" && data[0].SECURITYUSERFULLNAME2 ==""){
				 this.person2 = data[0].SECURITYUSERFULLNAME
				 this.person2Id = data[0].SECURITYUSERNAME
			}else if(data[0].SECURITYUSERFULLNAME == "" && data[0].SECURITYUSERFULLNAME2 != ""){
				 this.person2 = data[0].SECURITYUSERFULLNAME2
			 this.person2Id = data[0].SECURITYUSERNAME2
			}else{
        this.person2=""
        this.person2Id=""
      }
          this.person3 = data[0].SECURITYUSERFULLNAME
          this.person3Id = data[0].SECURITYUSERNAME
          this.person4 = data[0].SECURITYUSERFULLNAME2
          this.person4Id = data[0].SECURITYUSERNAME2
          console.log("person2",this.person2);
        })
      }
    }
  }
}
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
/* .transition-view /deep/.weui-cells__title {
      margin-top: 0.77em;
    margin-bottom: 0.3em;
    padding-left: 15px;
    padding-right: 15px;
    color: #353535;
    font-size: 14px;
} */
/* .transition-view /deep/ .vux-header .vux-header-left .left-arrow:before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.8);
  border-width: 1px 0 0 1px;
  -webkit-transform: rotate(315deg);
  transform: rotate(315deg);
  top: 8px;
  left: 7px;
}
.transition-view /deep/ .vux-header .vux-header-title {
  line-height: 40px;
  text-align: center;
  font-size: 18px;
  font-weight: 400;
  color: #333;
} */

#map {
  width: 100%;
  height: 25%;
}
.content {
  width: 100%;
  height: 75%;
}
.vux-x-icon {
  fill: #d9d9d9;
}
.cell-x-icon {
  display: block;
  fill: green;
}
.transition-view /deep/ .weui-cells__title {
  color: #333;
}
.cell_style {
  min-height: 38px;
}
.top-border{
  border-top: 1px solid #f5f5f5
}
.userBack-button_save{
      width: 40%;
      height: 40px;
      background-color: #ffffff;
      border-radius: 2pt;
      border: 1pt solid #4D86FF;
      margin-top: 20pt;
      color: #4D86FF;
      font-size: 13px;
      /* margin-left: 15px; */
        margin-right: auto;
      margin-left: auto;
      margin-bottom: 20pt;
  }
  .userBack-button_submit{
      width: 40%;
      height: 40px;
      background-color: #4D86FF;
      border-radius: 2pt;
      border: 1pt solid #4D86FF;
      margin-top: 20pt;
      color: #FFFFFF;
      font-size: 13px;
      /* margin-left: auto;
      margin-right: 5%; */
        margin-right: auto;
      margin-left: auto;
      margin-bottom: 20pt;
  }
  .sup{
  width: 100%;
  height: 10px;
  border-radius: 0;
  background-color: #F5F5F5;
}
</style>